using Framework;
using UnityEngine;
using UnityEngine.AI;

public class Res : ActorBase
{
    public Vector3 Pos;
    public bool RandomRotation;
    protected override void OnStart()
    {
        this.GameObject.transform.position = Pos;
        if(RandomRotation)
        {
            this.GameObject.transform.GetChild(0).rotation = Quaternion.Euler(Random.Range(-100, 100), Random.Range(-100, 100), Random.Range(-100, 100));
        }
        base.OnStart();
        var agent = this.GameObject.GetComponent<NavMeshAgent>();
        if (agent != null)
        {
            agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;
        }
        agent.Warp(Pos);
    }
    public override Vector3 GetWorldPosition()
    {
        if (this.IsGameObjectEnabled)
        {
            return this.GameObject.transform.position;
        }
        return Pos;
    }
    public override ActorType GetActorType()
    {
        return ActorType.Res;
    }
}